package com.jdbc.test;

import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Random;

import org.junit.Before;
import org.junit.Test;

import exception.MyException;
import mysql.*;

public class Teset {
	MySQLHandler handler = null;
	MySQLPool pool = null;
	ResultSet rs = null;
	Statement stmt = null;
		
	@Before
	public void init(){
		handler = new MySQLHandler();
		pool = new MySQLPool();
	}
	
	@Test
	public void testJDBC() throws Exception{
		String sql = "select * from user where user_password = 123456";
		rs = handler.query(sql);
		while(rs.next()){
			System.out.println(rs.getString("user_password"));
			System.out.println(rs.getString("user_id"));
		}
		//System.out.println(count);
	}
	
	@Test
	public void testInsert() throws MyException{
		String sql = "insert into user (user_id,user_password) values (10001,99999)";
		int a = handler.execute(sql);
		System.out.println(a);
	}
	
	@Test
	public void test2(){
		Random random = new Random();
		int a=random.nextInt(99);
		System.out.println(a);
	}
}
